package cn.fuck;

import java.util.Comparator;
import java.util.Objects;

public class Person implements Comparator<Person> {
    private double exp;

    public Person(double exp) {
        this.exp = exp;
    }

    @Override
    public int compare(Person o1, Person o2) {
        if (o1.exp == o2.getExp())
            return 0;
        return o1.exp - o2.getExp() > 0 ? 1 : -1;
    }

    public double getExp() {
        return exp;
    }

    public void setExp(double exp) {
        this.exp = exp;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (obj == this) {
            return true;
        }
        if (this.getClass() != obj.getClass()) {
            return false;
        }
        Person oth = (Person) obj;
        return Objects.equals(oth.getExp(), exp);
    }

    @Override
    public int hashCode() {
        return Objects.hash(exp);
    }

    @Override
    public String toString() {
        return "exp: " + exp;
    }
}
